package com.joven.shelltest.utils.sharefactory;

/**
 * @Author: wzj
 * @Date: 2024/4/8 11:30
 */
public class ShareTest {
    public static void main(String[] args) {
        CommodityFactory commodityFactory = new CommodityFactory();
        System.out.println("-------商品1-------");
        /**
         * 现有四家店铺，销售描述相同的手机，但每家点的库存不一样
         */
        // 店铺1
        Commodity phone1 = commodityFactory.getCommodityInstance("手机");
        phone1.sell(new Inventory(1000));
        // 店铺2
        Commodity phone2 = commodityFactory.getCommodityInstance("手机");
        phone2.sell(new Inventory(900));
        // 店铺3
        Commodity phone3 = commodityFactory.getCommodityInstance("手机");
        phone3.sell(new Inventory(800));
        // 店铺4
        Commodity phone4 = commodityFactory.getCommodityInstance("手机");
        phone4.sell(new Inventory(300));

        System.out.println("========校验是否是相同对象========");
        System.out.println("phone1 == phone2 ? " + (phone1 == phone2));
        System.out.println("phone2 == phone3 ? " + (phone2 == phone3));
        System.out.println("phone3 == phone4 ? " + (phone3 == phone4));

        System.out.println("-------商品2------测试略---");
        Commodity slipper = commodityFactory.getCommodityInstance("拖鞋");
        slipper.sell(new Inventory(10));
    }
}
